home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 176-200 / scopedisk180 / arexxtutorial / more_examples / arcall.rexx < prev    next >
OS/2 REXX Batch file  |  1995-03-19  |  1KB  |  46 lines

  1. /* arcall.rexx -  ARC all files within a directory, including subdirectories.
  2.                   Rename all files, generate a scriptto recreate the original
  3.                   file structure
  4. By Larry Phillips. Use this code in whatever way you like.
  5. */
  6.  
  7. arg root
  8. if right(root,1) ~= ':' then
  9.   root = root || '/'
  10. if root = '/' then root = ''
  11. filecount = 1
  12. dummy = open(execfile,root || 'Exec.me','write')
  13.  
  14. call renamefiles(root)
  15.  
  16. say
  17. call close(execfile)
  18. 'arc a arcfile *'
  19. exit 0
  20.  
  21. renamefiles: procedure expose filecount root
  22.   parse arg x
  23.   contents = showdir(x);
  24.   do i = 1 to words(contents)
  25.     temp = x || word(contents,i)
  26.     select
  27.       when word(statef(temp),1) = 'FILE' then do
  28.         rename temp root || 'File' || filecount
  29.         call writeln(execfile,'rename File' || filecount x || word(contents,i))
  30.         call writech(stdout,'.')
  31.         filecount = filecount + 1
  32.         end
  33.       when word(statef(temp),1) = 'DIR' then do
  34.         call writeln(execfile,'')
  35.         call writeln(execfile,'makedir' temp)
  36.         call renamefiles(temp || '/')
  37.       end
  38.       otherwise do
  39.         if translate(temp) = 'EXEC.ME' then break
  40.         else say 'Error: File' temp 'is neither DIR nor FILE.'
  41.       end
  42.     end
  43.   end
  44.   call writeln(execfile,'')
  45. return 0
  46.